axios.defaults.baseURL = 'http://www.itcbc.com:8000';





// 添加请求拦截器
axios.interceptors.request.use(function (config) {
  NProgress.start()
  if (localStorage.getItem('token82')) {
    config.headers.Authorization = localStorage.getItem('token82')
  }
  return config;
}, function (error) {
  // 对请求错误做些什么
  return Promise.reject(error);
});

// 添加响应拦截器
axios.interceptors.response.use(function (response) {
  
  if (response.data.code &&response.data.code !== 0) {
    toastr.error(response.data.message)
  }
  NProgress.done()
  // 对响应数据做点什么
  return response;
}, function (error) {
  NProgress.done()
  toastr.error(error.response.data.message)
  if (error.response.status === 401) {
    window.top.location.href = './login.html'
  }
  return Promise.reject(error);
});

//   提示框样式
toastr.options = {
  closeButton: true, // 显示 关闭按钮
  debug: false,
  positionClass: 'toast-top-center', // 提示框显示的位置
  onclick: null,
  showDuration: '300',
  hideDuration: '1000',
  timeOut: '5000',
  extendedTimeOut: '1000',
  showEasing: 'swing',
  hideEasing: 'linear',
  showMethod: 'fadeIn',
  hideMethod: 'fadeOut',
};